package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MatBadpheno;
import com.indusfo.spc.service.MatBadphenoService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/21 8:38
 * @Version 1.0
 */
@Controller
@RequestMapping("/service/matBadpheno")
public class MatBadphenoController {

    @Autowired
    private MatBadphenoService matBadphenoService;

    //查询
    @RequestMapping(value="/queryMatBadpheno")
    @ResponseBody
    public JSONObject queryMatBadpheno(MatBadpheno matBadpheno) {
        JSONObject json = matBadphenoService.queryMatBadpheno(matBadpheno);
        return json;
    }

    //新增
    @RequestMapping(value="/insertMatBadpheno", method= RequestMethod.POST)
    @ResponseBody
    public JSONObject insertMatBadpheno(MatBadpheno matBadpheno) {
        JSONObject json = matBadphenoService.insertMatBadpheno(matBadpheno);
        return json;
    }

    //修改
    @RequestMapping(value = "/updateMatBadpheno",method= RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMatBadpheno (MatBadpheno matBadpheno){
        JSONObject json=matBadphenoService.updateMatBadpheno(matBadpheno);
        return json;
    }

    //删除
    @RequestMapping(value="/deleteMatBadpheno", method= RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteMatBadpheno(@RequestParam("matBadphenoIds") List<Integer> matBadphenoIds, Integer dataState) {
        dataState = 2;
        JSONObject json = matBadphenoService.deleteMatBadpheno(matBadphenoIds, dataState);
        return json;
    }


    //启用/停用
    @RequestMapping(value="/definedMatBadpheno", method= RequestMethod.POST)
    @ResponseBody
    public JSONObject definedMatBadpheno(@RequestParam("matBadphenoIds") List<Integer> matBadphenoIds, Integer dataState) {
        JSONObject json = matBadphenoService.deleteMatBadpheno(matBadphenoIds, dataState);
        return json;
    }
}
